//
//  ViewController.m
//  iOS MD5Andbase64
//
//  Created by wanglei on 17/1/7.
//  Copyright © 2017年 wanglei. All rights reserved.
//

#import "ViewController.h"
#import "MySecurities.h"

@interface ViewController ()
@property(nonatomic,strong)NSString *str;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.str = @"I love you";
    //[self functionOne];
    [self functionTwo];
}

// MD5加密过程
- (void)functionOne{
    NSData *data = [_str dataUsingEncoding:NSUTF8StringEncoding];
    NSString *MD5str = [MySecurities md5String:_str];
    NSString *MD5data = [MySecurities md5Data:data];
    NSLog(@"MD5str = %@\nMD5data = %@",MD5str,MD5data);
}


// base64加密过程
- (void)functionTwo{
    NSLog(@"加密之前的字符串为%@",_str);
    NSData *aData = [_str dataUsingEncoding: NSUTF8StringEncoding];
    
    NSString *jiabase64str = [MySecurities base64EncodingWithData:aData];
    
    NSLog(@"加密之后的字符串为%@",jiabase64str);
    
    // base64解密过程
    
    NSData *data1 = [MySecurities base64EncodingWithString:jiabase64str];
    
    NSString *aString = [[NSString alloc] initWithData:data1 encoding:NSUTF8StringEncoding];
    NSLog(@"解密之后的字符串为%@",aString);
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
